﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.Logging;
using System.ComponentModel.Composition;

namespace ProjTemp.Common.Logging
{
    [Export(typeof(ILogger))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class Logger : ILogger
    {
        #region members and properties

        private ILog _innerLogger = null;

        private Type _logType = null;
        public Type LogType
        {
            get { return this._logType; }
            set
            {
                if (value != null)
                {
                    this._logType = value;
                    InitializeInnerLogger();
                }
            }
        }

        #endregion

        #region ctors

        public Logger()
        {
            this._logType = typeof(object);
            InitializeInnerLogger();
        }

        #endregion

        #region ILogger

        public void Trace(object message)
        {
            this._innerLogger.Trace(message);
        }

        public void Trace(object message, Exception exception)
        {
            this._innerLogger.Trace(message, exception);
        }

        public void TraceFormat(string format, params object[] args)
        {
            this._innerLogger.TraceFormat(format, args);
        }

        public void TraceFormat(string format, Exception exception, params object[] args)
        {
            this._innerLogger.TraceFormat(format, exception, args);
        }

        public void TraceFormat(IFormatProvider formatProvider, string format, params object[] args)
        {
            this._innerLogger.TraceFormat(formatProvider, format, args);
        }

        public void TraceFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
        {
            this._innerLogger.TraceFormat(formatProvider, format, exception, args);
        }

        public void Debug(object message)
        {
            this._innerLogger.Debug(message);
        }

        public void Debug(object message, Exception exception)
        {
            this._innerLogger.Debug(message, exception);
        }

        public void DebugFormat(string format, params object[] args)
        {
            this._innerLogger.DebugFormat(format, args);
        }

        public void DebugFormat(string format, Exception exception, params object[] args)
        {
            this._innerLogger.DebugFormat(format, exception, args);
        }

        public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args)
        {
            this._innerLogger.DebugFormat(formatProvider, format, args);
        }

        public void DebugFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
        {
            this._innerLogger.DebugFormat(formatProvider, format, exception, args);
        }

        public void Info(object message)
        {
            this._innerLogger.Info(message);
        }

        public void Info(object message, Exception exception)
        {
            this._innerLogger.Info(message, exception);
        }

        public void InfoFormat(string format, params object[] args)
        {
            this._innerLogger.InfoFormat(format, args);
        }

        public void InfoFormat(string format, Exception exception, params object[] args)
        {
            this._innerLogger.InfoFormat(format, exception, args);
        }

        public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args)
        {
            this._innerLogger.InfoFormat(formatProvider, format, args);
        }

        public void InfoFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
        {
            this._innerLogger.InfoFormat(formatProvider, format, exception, args);
        }

        public void Warn(object message)
        {
            this._innerLogger.Warn(message);
        }

        public void Warn(object message, Exception exception)
        {
            this._innerLogger.Warn(message, exception);
        }

        public void WarnFormat(string format, params object[] args)
        {
            this._innerLogger.WarnFormat(format, args);
        }

        public void WarnFormat(string format, Exception exception, params object[] args)
        {
            this._innerLogger.WarnFormat(format, exception, args);
        }

        public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args)
        {
            this._innerLogger.WarnFormat(formatProvider, format, args);
        }

        public void WarnFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
        {
            this._innerLogger.WarnFormat(formatProvider, format, exception, args);
        }

        public void Error(object message)
        {
            this._innerLogger.Error(message);
        }

        public void Error(object message, Exception exception)
        {
            this._innerLogger.Error(message, exception);
        }

        public void ErrorFormat(string format, params object[] args)
        {
            this._innerLogger.ErrorFormat(format, args);
        }

        public void ErrorFormat(string format, Exception exception, params object[] args)
        {
            this._innerLogger.ErrorFormat(format, exception, args);
        }

        public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args)
        {
            this._innerLogger.ErrorFormat(formatProvider, format, args);
        }

        public void ErrorFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
        {
            this._innerLogger.ErrorFormat(formatProvider, format, exception, args);
        }

        public void Fatal(object message)
        {
            this._innerLogger.Fatal(message);
        }

        public void Fatal(object message, Exception exception)
        {
            this._innerLogger.Fatal(message, exception);
        }

        public void FatalFormat(string format, params object[] args)
        {
            this._innerLogger.FatalFormat(format, args);
        }

        public void FatalFormat(string format, Exception exception, params object[] args)
        {
            this._innerLogger.FatalFormat(format, exception, args);
        }

        public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args)
        {
            this._innerLogger.FatalFormat(formatProvider, format, args);
        }

        public void FatalFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
        {
            this._innerLogger.FatalFormat(formatProvider, format, exception, args);
        }

        public bool IsTraceEnabled
        {
            get { return this._innerLogger.IsTraceEnabled; }
        }

        public bool IsDebugEnabled
        {
            get { return this._innerLogger.IsDebugEnabled; }
        }

        public bool IsErrorEnabled
        {
            get { return this._innerLogger.IsErrorEnabled; }
        }

        public bool IsFatalEnabled
        {
            get { return this._innerLogger.IsFatalEnabled; }
        }

        public bool IsInfoEnabled
        {
            get { return this._innerLogger.IsInfoEnabled; }
        }

        public bool IsWarnEnabled
        {
            get { return this._innerLogger.IsWarnEnabled; }
        }

        #endregion

        #region private methods

        private void InitializeInnerLogger()
        {
            this._innerLogger = LogManager.GetLogger(this._logType);
        }

        #endregion
    }
}
